<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<c:set var="jpath" value="${pageContext.request.contextPath }"/>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>用户列表</title>
		<meta name="keywords" content="Bootstrap模版,Bootstrap模版下载,Bootstrap教程,Bootstrap中文" />
		<meta name="description" content="站长素材提供Bootstrap模版,Bootstrap教程,Bootstrap中文翻译等相关Bootstrap插件下载" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		
		<%@include file="css.jsp"%>
	</head>

	<body>
<div class="page-content">
		<div class="page-header">
			<h1>
				Tables
				<small>
					<i class="icon-double-angle-right"></i>
					Static &amp; Dynamic Tables
				</small>
			</h1>
		</div><!-- /.page-header -->
		<div class="row">
			<div class="col-xs-12">
				<!-- PAGE CONTENT BEGINS -->
				<div class="row">
					<div class="col-xs-12">
						<div class="table-responsive">
							<table id="sample-table-1" class="table table-striped table-bordered table-hover">
								<thead>
									<tr>
										<th class="center">
											<label>
												<input id="ch" type="checkbox" class="ace" value="全选" />
												<span class="lbl"></span>
											</label>
										</th>
										<th>标题</th>
										<th class="hidden-480">时间</th>
										<th>简介</th>
										<th>条件</th>
										<th>流程</th>
										<th>联系我们</th>
										<th>产品分类</th>
										<th>产品状态</th>
										<th>发布人</th>
										<th>发布时间</th>
										<th>操作</th>
										<th>审核</th>
									</tr>
								</thead>

								<tbody>
									
								</tbody>
							</table>
						</div><!-- /.table-responsive -->
					</div><!-- /span -->
				</div><!-- /row -->
			</div><!-- /.col -->
		</div><!-- /.row -->
		<div id="xuhaoRong" class="modal-footer no-margin-top">
			<button class="btn btn-app btn-danger btn-sm" style="float: left;" onClick=delMBtn(0);>
				<i class="icon-trash bigger-200"></i>
				批量删除
			</button>
	
			<button class="btn btn-app btn-purple btn-sm"  style="float: left;" onClick=insertBtn(0); >
				<i class="icon-cloud-upload bigger-200"></i>
				添加
			</button>
			<ul id="xuhao" class="pagination pull-right no-margin" style="padding-top: 45px;">
			</ul>
		</div>
							

	</div><!-- /.page-content -->
<%@include file="js.jsp"%>
<script type="text/javascript">
	function delMBtn(id){
		var delId=new Array();
		$("input[type='checkbox']").each(function(index) {
			if ($(this).is(':checked') == true) {
		  		delId[index] = $(this).val(); 
			} 
		});
		var str = delId.toString();
		$.post("${jpath}/product/deleteBatch",{uiCheck:str},function(data){
				var json = $.parseJSON(data);
				alert(json.resMsg);
				if(json.resMsg=="批量删除成功"){
					var hrefStr = "${jpath}/productContent";
					location.href=hrefStr;
				};
			}
		);
	};
	function delBtn(id){
		$.post("${jpath}/product/delect",{id:id},
			function(data){
				var json = $.parseJSON(data);
				alert(json.resMsg);
				if(json.resMsg=="删除成功"){
					var hrefStr = "${jpath}/productContent";
					location.href=hrefStr;
				};
			}
		);
	};
	function updateBtn(id){
		var timePString = $("#timePString").val();
		var hrefStr = "${jpath}/product/productInfo?id="+id+"&timePString="+timePString;
		location.href=hrefStr;
	};
	function insertBtn(id){
		var hrefStr = "${jpath}/product/productInfo?id="+id;
		location.href=hrefStr;
	};
	function checkTrueBtn(state,id){
		alert("通过审核");
		var hrefStr = "${jpath}/product/productState?state="+state+"&id="+id;
		location.href=hrefStr;
	};
	function checkFalseBtn(state,id){
		alert("审核失败");
		var hrefStr = "${jpath}/product/productState?state="+state+"&id="+id;
		location.href=hrefStr;
	};
	$(function(){
		//loadTbl(1,$("#xuhao").find("li[class='active']"));
		var colM=[{
			name:'id',
			cl:function(index,val){
				return '<label><input type="checkbox" name="check" class="ace" value="'+val+'"/><span class="lbl"><input type="hidden"></span></label>';
				}
			},{
				name:'title'
			},{
				name:'timePString',
				cl:function(index,val){
				return val+'<input type="hidden" id="timePString" value="'+val+'"></span>';
				}
			},{
				name:'synopsis',
			},{
				name:'conditionP'
			},{
				name:'processP'
			},{
				name:'contactUs'
			},{
				name:'classification'
			},{
				name:'state'
			},{
				name:'publisher'
			},{
				name:'releaseTimeString'
			},{
				name:'id',
				cl:function(index,val){
					return '<div class="btn-group"><button class="btn btn-xs btn-info" onclick="updateBtn(\''+val+'\')"><i class="icon-edit bigger-120"></i></button><button class="btn btn-xs btn-danger" onclick="delBtn(\''+val+'\')"><i class="icon-trash bigger-120"></i></button></div>';
				}
			},{
			name:'id',
			cl:function(index,val){
				return '<div class="btn-group"><button class="btn btn-xs btn-info" onclick="checkTrueBtn(100,\''+val+'\')"><i bigger-120">通过</i></button><input type="hidden" id="state" name="state" value=""></div><div class="btn-group"><button class="btn btn-xs btn-danger" onclick="checkFalseBtn(200,\''+val+'\')"><i bigger-120">拒绝</i></button><input type="hidden" id="state" name="state" value=""></div>';
				}
			}];
		var pasrams={pageNum:1,pageSize:2};		
		$("#sample-table-1").loadTbl(colM,pasrams,"${jpath}/product/findByPage",true);
		
		
		 $("#ch").click(function(){
          //转化为JQ对象并调用prop方法获取属性
          //alert($(this).prop("checked"));
               //获取其他复选框，使用prop方式设置属性与全选框保持一致
         	 $("input[type='checkbox']").prop("checked",$(this).prop("checked"));  
          });
	}
	);
</script>
</body>
</html>
